<?php

require_once '../../config.php';

if ($_POST) {
  $operator = operators_get_account();
  messages_send_from_operator($_POST['message'], $operator, $_GET['sessionId']);
}
?>

<?php 
$hidePanels = true;
include dirname(__FILE__) . '/../header.php' 
?>

<?php if (empty($_GET['sessionId'])): ?>
  <h2>Operators Chat</h2>
<?php else: ?>
  <h2>Chat with visitor</h2>
<?php endif ?>

<div style="border:1px solid #ccc;width:400px;margin-bottom:10px;height:310px;overflow:auto;background:#eee">
  <a class="Periodical" style="overflow:scroll" rel="/account/ajax/messages.php?sessionId=<?php echo $_GET['sessionId'] ?>"></a>
</div>

<form method="POST" action="" id="OperatorChatMessageForm">
  <textarea name="message" id="OperatorChatMessage"></textarea><br />
  <input type="submit" value="Send" />
</form>

<script type="text/javascript">
  $("#OperatorChatMessageForm").ajaxForm(function() {
    $("#OperatorChatMessage").val("");
    LcHelper.load();
  });  
</script>

<?php include dirname(__FILE__) . '/../footer.php' ?>
